using System;
using System.Collections.Generic;
using LinearAlgebra.Matrices;

namespace LinearAlgebra.Vectors
{
	/// <summary>
	/// An RowCount-Dimensioned collection of things, lets us use linear algebra terminology rather than Lists and Sets and such
	/// </summary>
	/// <typeparam name="T">The type of the vector</typeparam>
	public class Vector<T> : List<T>
	{
		protected Vector() {} //for simpler vectors
		
		protected Vector( int size ) : base( size ) {}		
		
		public int Length { get { return this.Count; } }

		protected static void AssertSize( Vector<T> A, Vector<T> B )
		{
			if( A.Count != B.Count ) //the vectors are not the same size
				throw new Exception( 
					String.Format("Vectors are not the same size A:B=({0}+{1}), operation is undefined.", 
						A.Count, B.Count ) ); //end checking the dim of the input vectors
		}		
		
		public void Swap( int i1, int i2 )
		{
			T tmp		= this[i1];
			this[i1]	= this[i2];
			this[i2]	= tmp;
		}

		public Vector<T> Shuffle( int seed )
		{
			Random r = new Random( seed );
			for( int i = 0; i < this.Length; i++ )
				Swap( i, r.Next( 0, Length ) );
			return this;
		}
	}
}